module DecFoward(
icode, 
r,
CC, 
val_i, 
dstE_e, 
dstM_e, 
dstE_m, 
dstM_m, 
dstE_w, 
dstM_w,
valE_e,
valM_e,
valE_m,
valM_m,
valE_w,
valM_w,
val_o,
WAIT);

input [3:0] icode;
input [3:0] r;
input [31:0] CC;
input [31:0] val_i;
input [3:0] dstE_e;
input [3:0] dstM_e;
input [3:0] dstE_m;
input [3:0] dstM_m;
input [3:0] dstE_w;
input [3:0] dstM_w;
input [31:0] valE_e;
input [31:0] valM_e;
input [31:0] valE_m;
input [31:0] valM_m;
input [31:0] valE_w;
input [31:0] valM_w;

output reg [31:0] val_o;
output reg WAIT;

always @(*) begin
	if(icode == 10 && r == 4'h8) begin
		val_o <= CC;
		WAIT <= 0;
	end else if(dstE_e == r) begin
		val_o <= valE_e;
		WAIT <= 0;
	end else if(dstM_e == r) begin
		val_o <= val_i;
		WAIT <= 1;
	end else if(dstE_m == r) begin
		val_o <= valE_m;
		WAIT <= 0;
	end else if(dstM_m == r) begin
		val_o <= valM_m;
		WAIT <= 0;
	end else if(dstE_w == r) begin
		val_o <= valE_w;
		WAIT <= 0;
	end else if(dstM_w == r) begin
		val_o <= valM_w;
		WAIT <= 0;
	end else begin
		val_o <= val_i;
		WAIT <= 0;
	end
end


endmodule
